home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / intuition / openwindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  3.4 KB  |  148 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: openwindow.c,v 1.2 1996/08/29 13:33:32 digulla Exp $
  4.     $Log: openwindow.c,v $
  5.     Revision 1.2  1996/08/29 13:33:32  digulla
  6.     Moved common code from driver to Intuition
  7.     More docs
  8.  
  9.     Revision 1.1  1996/08/13 15:37:27  digulla
  10.     First function for intuition.library
  11.  
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include "intuition_intern.h"
  17. #include <exec/memory.h>
  18. #include <intuition/intuition.h>
  19. #include <clib/exec_protos.h>
  20. #include <clib/graphics_protos.h>
  21.  
  22. extern int intui_OpenWindow (struct Window *,
  23.         struct IntuitionBase *);
  24. extern int intui_GetWindowSize (void);
  25.  
  26. /*****************************************************************************
  27.  
  28.     NAME */
  29.     #include <intuition/intuition.h>
  30.     #include <clib/intuition_protos.h>
  31.  
  32.     __AROS_LH1(struct Window *, OpenWindow,
  33.  
  34. /*  SYNOPSIS */
  35.     __AROS_LHA(struct NewWindow *, newWindow, A0),
  36.  
  37. /*  LOCATION */
  38.     struct IntuitionBase *, IntuitionBase, 34, Intuition)
  39.  
  40. /*  FUNCTION
  41.     Opens a new window with the characteristiks specified in
  42.     newWindow.
  43.  
  44.     INPUTS
  45.     newWindow - How you would like your new window.
  46.  
  47.     RESULT
  48.     A pointer to the new window or NULL if it couldn't be
  49.     opened. Reasons for this might be lack of memory or illegal
  50.     attributes.
  51.  
  52.     NOTES
  53.  
  54.     EXAMPLE
  55.  
  56.     BUGS
  57.  
  58.     SEE ALSO
  59.     CloseWindow(), ModifyIDCMP()
  60.  
  61.     INTERNALS
  62.  
  63.     HISTORY
  64.     29-10-95    digulla automatically created from
  65.                 intuition_lib.fd and clib/intuition_protos.h
  66.  
  67. *****************************************************************************/
  68. {
  69.     __AROS_FUNC_INIT
  70.     __AROS_BASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  71.     struct Window * w;
  72.     struct RastPort * rp;
  73.  
  74.     w  = AllocMem (intui_GetWindowSize (), MEMF_CLEAR);
  75.     rp = AllocMem (sizeof (struct RastPort), MEMF_CLEAR);
  76.  
  77.     if (!w || !rp)
  78.     goto failexit;
  79.  
  80.     if (!ModifyIDCMP (w, newWindow->IDCMPFlags))
  81.     goto failexit;
  82.  
  83.     w->LeftEdge    = newWindow->LeftEdge;
  84.     w->TopEdge       = newWindow->TopEdge;
  85.     w->Width       = newWindow->Width;
  86.     w->Height       = newWindow->Height;
  87.     w->RPort       = rp;
  88.     w->FirstGadget = newWindow->FirstGadget;
  89.  
  90.     if (newWindow->DetailPen == 0xFF) newWindow->DetailPen = 1;
  91.     if (newWindow->BlockPen  == 0xFF) newWindow->BlockPen = 0;
  92.  
  93.     w->BorderLeft   = 0;
  94.     w->BorderTop    = 0;
  95.     w->BorderRight  = 0;
  96.     w->BorderBottom = 0;
  97.  
  98.     w->MinWidth  = newWindow->MinWidth;
  99.     w->MinHeight = newWindow->MinHeight;
  100.     w->MaxWidth  = newWindow->MaxWidth;
  101.     w->MaxHeight = newWindow->MaxHeight;
  102.  
  103.     if (newWindow->Type == PUBLICSCREEN)
  104.     w->WScreen = IntuitionBase->ActiveScreen;
  105.     else if (newWindow->Type == CUSTOMSCREEN)
  106.     w->WScreen = newWindow->Screen;
  107.     else
  108.     w->WScreen = GetPrivIBase (IntuitionBase)->WorkBench;
  109.  
  110.     if (!intui_OpenWindow (w, IntuitionBase))
  111.     goto failexit;
  112.  
  113.     SetFont (rp, GfxBase->DefaultFont);
  114.     SetAPen (rp, newWindow->DetailPen);
  115.     SetBPen (rp, newWindow->BlockPen);
  116.     SetDrMd (rp, JAM2);
  117.  
  118.     SetWindowTitles (w, newWindow->Title, (STRPTR)-1);
  119.  
  120.     w->Parent = NULL;
  121.     w->NextWindow = w->Descendant = w->WScreen->FirstWindow;
  122.     w->WScreen->FirstWindow = w;
  123.  
  124.     if (newWindow->Flags & ACTIVATE)
  125.     IntuitionBase->ActiveWindow = w;
  126.  
  127.     RefreshGadgets (w->FirstGadget, w, NULL);
  128.  
  129.     goto exit;
  130.  
  131. failexit:
  132.     ModifyIDCMP (w, 0L);
  133.  
  134.     if (rp)
  135.     FreeMem (rp, sizeof (struct RastPort));
  136.  
  137.     if (w)
  138.     {
  139.     FreeMem (w, intui_GetWindowSize ());
  140.  
  141.     w = NULL;
  142.     }
  143.  
  144. exit:
  145.     return w;
  146.     __AROS_FUNC_EXIT
  147. } /* OpenWindow */
  148.